/**
 * 定义ui公共模块
 */
(function(window, angular, undefined){

	var nav = angular.module('water.common.nav',[]);
	
	nav.factory('$nav',function($rootScope){
		var $ui = {
			/**
			 * 当前state是否选中
			 */
			isSelected: function(stateName){
				if(!$rootScope.stateName){
					return "";
				}
				var className = $rootScope.stateName.indexOf(stateName) > -1 ?'selected':'';
				return className;
			}
		};
		/**
		 * 当前state是否选中
		 */
		this.isSelected = function(stateName){
			var className = $rootScope.stateName.indexOf(stateName) > -1 ?'selected':'';
			return className;
		}
		$rootScope.ui = {};
		for(f in $ui){
			$rootScope.ui[f] = $ui[f];
		}
		return $ui;
	});
	
	nav.run(function($rootScope){
		$rootScope.$on('$stateChangeStart',
	            function(event, toState, toParams, fromState, fromParams){
				 	$rootScope.stateName = toState.name;
			 	}
			 );
	});
	
}(window, angular));